# Copyright (C) 2009,2010,2011,2012  Marco Restelli
#
# This file is part of:
#   LDGH -- Local Hybridizable Discontinuous Galerkin toolkit
#
# LDGH is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# LDGH is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LDGH. If not, see <http://www.gnu.org/licenses/>.
#
# author: Marco Restelli                   <marco.restelli@gmail.com>


# This Makefile handles the dependencies among the subfolders of the
# src folder. It should be called by the main Makefile, where the
# compiler options are defined, and it should never be modified
# directly: all the configuration options are in the main Makefile.

# General settings -----------------------------------

# clear unfinished targets
.DELETE_ON_ERROR:
# exported variables (the same as in the main Makefile)
export EXPORTED_VARS $(EXPORTED_VARS)
# define the phony targets
# Notice that at this level we don't know the detailed prerequisites
# of the main targets, so we have to define all the main targets as
# phony. This way, we always cd into the particular folder and check
# the detailed prerequisites.
.PHONY: clean libshared libode ode-test \
        wandzuraxiao cools-encyclopedia \
	cg ldgh ldghf psi               \
	cg-stokes cg-ns dg-comp         \
	cg-dd

# Main targets ---------------------------------------

wandzuraxiao cools-encyclopedia: libshared
	cd ./numerical-quadrature; $(MAKE) $@

cg ldgh ldghf psi: libshared
	cd ./ADR; $(MAKE) $@

cg-stokes cg-ns dg-comp: libshared libode liblinsol
	cd ./NS; $(MAKE) $@

cg-dd: libshared liblinsol
	cd ./SC; $(MAKE) $@

libshared:
	cd ./shared; $(MAKE)

libode ode-test: libshared
	cd ./time-integrators; $(MAKE)

liblinsol: libshared
	cd ./linear-solvers; $(MAKE)

clean:
	cd ./shared; $(MAKE) clean
	cd ./time-integrators; $(MAKE) clean
	cd ./linear-solvers; $(MAKE) clean
	cd ./numerical-quadrature; $(MAKE) clean
	cd ./ADR; $(MAKE) clean
	cd ./NS; $(MAKE) clean
	cd ./SC; $(MAKE) clean

